<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/base.jsp"%>
<% 
  //实例化AreaDao
  AreaDao areaDao=new AreaDao();
  int[]grades={4};
  List<Area> areaList=areaDao.findListByGrade(grades);
  
  FamilyDao familyDao=new FamilyDao();
  List<Family> familyCodelast=familyDao.findRencent();
  String code = familyCodelast.get(0).getFamilycode();
  System.out.println("当前最近的家庭编号===="+code);
  String last = code.substring(code.length()-4, code.length());
  int addNumber = Integer.parseInt(last);
  System.out.println("家庭编号的后四位===="+last);
  session.setAttribute("zhege",last);

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<link rel="stylesheet" type="text/css" href="css/styles.css">
<link rel="stylesheet" type="text/css" href="css/admin.css">

<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="js/admin.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		//重新绑定表单提交
		$("#add_btn").bind("click", function() {
			$('form').submit();
		});
	});
</script>

</head>

<body>

	<div class="panel admin-panel">
		<div class="panel-head" id="add">
			<strong><span class="icon-pencil-square-o"></span>增加家庭档案信息</strong>
		</div>
		<div class="body-content">
			<form id="form-add" method="post" class="form-x"
				action="<%=path%>/system/FamilyServlet?m=add">
				<div class="form-group">
					<div class="label">
						<label>所属地区：</label>
					</div>
					<div class="field">
						<select id="areacode" name="areacode" class="input w50">
							<%
						  for(Area m:areaList){ 
						
						  %>
							<option value="<%=m.getAreacode()%>">
								<%
						  
						  for(int i=0;i<m.getGrade();i++){
							 if(i==0){
								 out.print("|-"); 
							 }else{
								 out.print("-");
							 }
							  
						  } %>
								<%=m.getAreaname() %></option>
							<%} %>

						</select>


						<div class="tips"></div>
					</div>

				</div>
				<%int one=1; %>
				<div class="form-group">
					<div class="label">
						<label>家庭编码：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" style="width: 160px;" value="" name="first" id="familycode"
							data-validate="required:请输入家庭编码" /><input name="next" style="width: 150px;" class="input w50" type="text" value="-<%=addNumber+one %>"/>
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>户属性：</label>
					</div>
					<div class="field">
						<select id="familyattribute" name="familyattribute" class="input w50">
						  <option value="">---请选择---</option>
						  <option value="一般户">一般户</option>
						  <option value="五保户">五保户</option>
						  <option value="军烈属">军烈属</option>
						  <option value="其他">其他</option>
						</select>
						<div class="tips"></div>
					</div>
				</div>
				<!-- <div class="form-group">
					<div class="label">
						<label>家庭人口数：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="" name="population"
							data-validate="required:请输入家庭人口数" />
						<div class="tips"></div>
					</div>
				</div> -->
				<div class="form-group">
					<div class="label">
						<label>农业人口数：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="" name="farmpopulation"
							data-validate="required:请输入农业人口数" />
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>家庭住址：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="" name="familyaddress"
							data-validate="required:请输入家庭住址" />
						<div class="tips"></div>
					</div>
				</div>
				<!-- <div class="form-group">
					<div class="label">
						<label>创建时间：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="2019-04-16" name="creattime"
							data-validate="required:请输入户主姓名" />
						<div class="tips"></div>
					</div>
				</div> -->
				<div class="form-group">
					<div class="label">
						<label>登记员：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="<%=session.getAttribute("userid").toString() %>" name="registrar"
							data-validate="required:请输入登记员" />
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>户主姓名：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="" name="familyholdername"
							data-validate="required:请输入户主姓名" />
						<div class="tips"></div>
					</div>
				</div>


				<div class="form-group">
					<div class="label">
						<label></label>
					</div>
					<div class="field">
						<button id="add_btn" class="button bg-main icon-check-square-o"
							type="button">提交</button>
					</div>
				</div>
			</form>
		</div>
	</div>
<script type="text/javascript">
/*
 * 获取组的编号设置家庭编号
 */
var testSelect = document.getElementById("areacode");
testSelect.onchange = function() { //当选项改变时触发
    var valOption = this.options[this.selectedIndex].value; //获取option的value
    $('#familycode').val(valOption);//放到input的value中
}
</script>
</body>
</html>
